package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.BatchDeleteRequest;
import com.mes.cloud.api.dto.request.employee.BindRoleRequest;
import com.mes.cloud.api.dto.request.employee.EmployeeIsMainRoleRequest;
import com.mes.cloud.api.dto.request.employee.RolePageListRequest;
import com.mes.cloud.api.dto.request.role.BindEmployeeRequest;
import com.mes.cloud.api.dto.request.role.EmployeePageListRequest;
import com.mes.cloud.api.dto.response.employee.RoleListDto;
import com.mes.cloud.api.dto.response.role.RoleEmployeeDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.SysEmployeeRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wxm
 * @version 2019-08-02 15:02:43
 * @email xiaomin.wu1@pactera.com
 */
@Api(tags = "角色用户关联表", value = "角色用户关联表接口")
@RestController
@RequestMapping(value = "/sysEmployeeRole")
public class SysEmployeeRoleController  {

    private SysEmployeeRoleService sysEmployeeRoleService;

    @Autowired
    public SysEmployeeRoleController(SysEmployeeRoleService sysEmployeeRoleService) {
        this.sysEmployeeRoleService = sysEmployeeRoleService;
    }

    /**
     * 角色界面查看员工列表
     *
     * @param employeePageListRequest
     * @return
     */
    @ApiOperation(value = "角色界面查看员工列表", notes = "角色界面查看员工列表")
    @PostMapping(value = "/employeePageList")
    public JsonResult<CommPager<RoleEmployeeDto>> employeePageList(@RequestBody EmployeePageListRequest employeePageListRequest) {
        return sysEmployeeRoleService.employeePageList(employeePageListRequest);
    }

    /**
     * 员工界面查看角色列表
     *
     * @param rolePageListRequest
     * @return
     */
    @ApiOperation(value = "员工界面查看角色列表", notes = "员工界面查看角色列表")
    @PostMapping(value = "/rolePageList")
    public JsonResult<CommPager<RoleListDto>> rolePageList(@RequestBody RolePageListRequest rolePageListRequest) {
        return sysEmployeeRoleService.rolePageList(rolePageListRequest);
    }

    /**
     * 角色增加员工
     *
     * @param bindEmployeeRequest
     * @return
     */
    @ApiOperation(value = "角色增加员工", notes = "角色增加员工")
    @PostMapping(value = "/bindEmployee")
    public JsonResult bindEmployee(@RequestBody BindEmployeeRequest bindEmployeeRequest) {
        return sysEmployeeRoleService.bindEmployee(bindEmployeeRequest);
    }

    /**
     * 员工添加角色
     *
     * @param bindRoleRequest
     * @return
     */
    @ApiOperation(value = "员工添加角色", notes = "员工添加角色")
    @PostMapping(value = "/bindRole")
    public JsonResult bindRole(@RequestBody BindRoleRequest bindRoleRequest) {
        return sysEmployeeRoleService.bindRole(bindRoleRequest);
    }

    /**
     * 批量移除关联关系
     *
     * @param batchDeleteRequest
     * @return
     */
    @ApiOperation(value = "批量移除关联关系", notes = "批量移除关联关系")
    @PostMapping(value = "/batchDelete")
    public JsonResult batchDelete(@RequestBody BatchDeleteRequest batchDeleteRequest) {
        return sysEmployeeRoleService.batchDelete(batchDeleteRequest);
    }


    /**
     * 是否主角色
     *
     * @param employeeIsMainRoleRequest
     * @return
     */
    @ApiOperation(value = "是否主角色", notes = "是否主角色")
    @PostMapping(value = "/isMainRole")
    public JsonResult isMainRole(@RequestBody EmployeeIsMainRoleRequest employeeIsMainRoleRequest) {
        return sysEmployeeRoleService.isMainRole(employeeIsMainRoleRequest);
    }
}
